Security News
JSR Working Group Kicks Off with Ambitious Roadmap and Plans for Open Governance
At its inaugural meeting, the JSR Working Group outlined plans for an open governance model and a roadmap to enhance JavaScript package management.
@graphql-tools/schema
Advanced tools
The @graphql-tools/schema package is a utility library that helps with the creation and manipulation of GraphQL schemas. It provides functions to make it easier to work with GraphQL schema definitions, including merging type definitions, adding resolvers, and more.
makeExecutableSchema
This feature allows you to combine type definitions and resolvers to create an executable GraphQL schema.
const { makeExecutableSchema } = require('@graphql-tools/schema');
const typeDefs = `
type Query {
hello: String
}
`;
const resolvers = {
Query: {
hello: () => 'Hello world!',
},
};
const schema = makeExecutableSchema({
typeDefs,
resolvers,
});
addResolversToSchema
This feature enables you to add new resolvers to an existing GraphQL schema.
const { addResolversToSchema } = require('@graphql-tools/schema');
const schema = makeExecutableSchema({ typeDefs });
const resolvers = {
Query: {
hello: () => 'Hello world!',
},
};
addResolversToSchema({ schema, resolvers });
addSchemaLevelResolver
This feature allows you to add a resolver function that runs before any other resolvers for each operation.
const { addSchemaLevelResolver } = require('@graphql-tools/schema');
const schema = makeExecutableSchema({ typeDefs, resolvers });
const rootResolver = (root, args, context, info) => { /*...*/ };
addSchemaLevelResolver(schema, rootResolver);
This is a more comprehensive package that includes @graphql-tools/schema as a part of its toolkit. It provides additional utilities for mocking and stitching GraphQL schemas.
While not a direct alternative, Apollo Server uses similar concepts and includes the ability to create an executable schema. It is a full-featured GraphQL server that integrates well with @graphql-tools/schema.
This package provides functionality to merge GraphQL type definitions and resolvers. It is similar to some of the features in @graphql-tools/schema but is more focused on the merging aspect.
Check API Reference for more information about this package; https://www.graphql-tools.com/docs/api/modules/schema_src
You can also learn more about Generating Executable Schemas in this chapter; https://www.graphql-tools.com/docs/generate-schema
FAQs
A set of utils for faster development of GraphQL tools
The npm package @graphql-tools/schema receives a total of 7,133,729 weekly downloads. As such, @graphql-tools/schema popularity was classified as popular.
We found that @graphql-tools/schema demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 3 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
At its inaugural meeting, the JSR Working Group outlined plans for an open governance model and a roadmap to enhance JavaScript package management.
Security News
Research
An advanced npm supply chain attack is leveraging Ethereum smart contracts for decentralized, persistent malware control, evading traditional defenses.
Security News
Research
Attackers are impersonating Sindre Sorhus on npm with a fake 'chalk-node' package containing a malicious backdoor to compromise developers' projects.